// pages/myOrder/myOrder.js
var usedata = require("../myOrderdata/myOrderdata.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    myOrderdata:'',
    navData: [
      {
        text: '待付款'
      },      
      {
        text: '配送中'
      },
      {
        text: '历史订单'
      },
      {
        text: '长停中'
      },
            
    ],
    currentTab: 0,//头部选中下标
    navScrollLeft: 0,//内容选中下标
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      myOrderdata: usedata.myOrderdata
    })
  },
  switchNav(event) {
    var cur = event.currentTarget.dataset.current;
    //每个tab选项宽度占1/3
    var singleNavWidth = this.data.windowWidth / (this.data.navData.lenght);
    //tab选项居中                            
    this.setData({
      navScrollLeft: (cur - 2) * singleNavWidth
    })
    if (this.data.currentTab == cur) {
      return false;
    } else {
      this.setData({
        currentTab: cur
      })
    }
  },
  switchTab(event) {
    var cur = event.detail.current;
    var singleNavWidth = this.data.windowWidth / (this.data.navData.lenght);
    this.setData({
      currentTab: cur,
      navScrollLeft: (cur - 2) * singleNavWidth
    });
  },
  goAddress: function () {//跳转地址页面
    wx.navigateTo({
      url: '../address/address'
    })
  },
})